{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import time\n",
    "import os\n",
    "import pandas as pd\n",
    "#os.chdir(\"/home/CWSHPMU2316/Desktop/EVRangePrediction/data/raw\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "# list of all the vehicles used in analysis\n",
    "# this list will help in randomly selecting the files to be used in analysis\n",
    "\n",
    "vehicleList = [352891066262326, 352891066262722, 352891066262995, 352891066263282, 352891066264694, 352891066265451, \\\n",
    "               358272088698868, 358272088699007, 358272088699072, 358272088701548, 358272088709954, 358272088712370, \\\n",
    "               358272088715043, 358272088715191, 358272088716215, 358272088718575, 358272088730844]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Generating a random within a certain window (1 November 2018 to 27 January 2019)\n",
    "\n",
    "def randomDate(start, end, format, prop):\n",
    "    stime = time.mktime(time.strptime(start, format))\n",
    "    etime = time.mktime(time.strptime(end, format))\n",
    "    ptime = stime + prop * (etime - stime)\n",
    "    return time.strftime(format, time.localtime(ptime))\n",
    "\n",
    "\n",
    "def randomDateGenerator(start, end, prop):\n",
    "    return randomDate(start, end, '%Y-%m-%d', prop)\n",
    "\n",
    "def csv():\n",
    "    return str(random.choice(vehicleList))+\"_\"+randomDateGenerator(\"2018-11-01\", \"2019-01-27\", random.random()) + \"_cb.csv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = csv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = \"/home/CWSHPMU2316/Desktop/EVRangePrediction/data/raw/\" + a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/CWSHPMU2316/Desktop/EVRangePrediction/data/raw/358272088716215_2018-12-17_cb.csv'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "358272088715191_2018-11-21_cb.csv\n"
     ]
    }
   ],
   "source": [
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
